#Twisted Shootout
#Copyright (C) 2007  Han Dao
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#You can contact the author at wikipediankiba@gmail.com
import pygame
import data
import weapon

class WeaponTracker():
	def __init__(self,sprites):
		self.w = []
		self.sprites = sprites
		self.ammo = 0
		self.e = 0
		self.x = 10
		self.y = 0
	def bullets(self,x,y,c = 0):
		self.w.append(weapon.Weapon())
		y = y + 25
		if c == 0:
			self.w[-1].x = self.x
		else:
			self.w[-1].x = c
			self.sprites.add(self.w[-1])
		self.w[-1].rect.x = x + 30 
		self.w[-1].rect.y = y
		self.answer = self.w[-1]
	def shoot(self,x,y):
		self.ammo = self.ammo + 1
		if self.ammo >= 101:
			return False
		self.bullets(x,y)
		return self.answer
	def enemyfire(self,x,y,c):
		if c == 10:
			x = x + 20
		elif c == -10:
			x = x - 40
		self.bullets(x,y,c)
		return self.answer
	def move(self):
		n = 0
		for w in self.w:
			w.move()
			if w.tick > 25:
				self.sprites.remove(self.w[n])
				self.w.pop(n)
			n = n + 1